package jsmc.opendata.pratikanant.activity;


import java.io.IOException;

import jsmc.android.utils.DataBaseHelper;
import jsmc.opendata.pratikanant.Constants;
import jsmc.opendata.pratikanant.MainGDActivity;
import jsmc.opendata.pratikanant.R;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class HomeActivity extends MainGDActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setActionBarContentView(R.layout.home);

		DataBaseHelper myDbHelper = new DataBaseHelper(this,Constants.DB_PATH,Constants.DB_NAME);
		try {

			myDbHelper.createDataBase();

		} catch (IOException ioe) {

			throw new Error("Unable to create database");

		}
		

		((Button) findViewById(R.id.home_button_parkings)).setOnClickListener( mParkingListener );
		((Button) findViewById(R.id.home_button_temps_parcours)).setOnClickListener(mTempsParcoursListener);

	}

	/**
	 * A call-back for parkingbutton
	 */
	OnClickListener mParkingListener = new OnClickListener() {
		public void onClick(View v) {

			startActivity(new Intent(getApplicationContext(), ParkingsActivity.class));

		}
	};

	/**
	 * A call-back for parkingbutton
	 */
	OnClickListener mTempsParcoursListener = new OnClickListener() {
		public void onClick(View v) {

			startActivity(new Intent(getApplicationContext(), TempsParcours.class));

		}
	};   


}